const express = require('express');
const router = express.Router();
const loginCheck = require('../middleware/loginCheck');
const {diaryAdd} = require('../controller/user');
const {SuccessModel, ErrorModel} = require('../model/resModel');


router.post('/user/diary/add',loginCheck, function(req, res, next) {
    const { title,content,weather } = req.body;
    const {username} = req.session;
    const result = diaryAdd(username,title,content,weather);
    return result.then(data => {
        if(data){
            res.json(new SuccessModel('添加成功'))
        }
    });
});

module.exports = router;